﻿717.1比特与2比特字符
bool isOneBitCharacter(int* bits, int bitsSize) {
    int i;
    for (i = 0; i < bitsSize; i++)
    {
        if (bits[i] == 1)
        {
            i++;
        }
        else if (bits[i] == 0)
        {
            if (i == bitsSize - 1)
            {
                return true;
            }
        }
    }

    return false;
}

728.自除数
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* selfDividingNumbers(int left, int right, int* returnSize) {
    int* ans = (int*)malloc(sizeof(int) * (right - left));
    *returnSize = 0;

    for (int i = left; i <= right; i++)
    {
        int temp = i;
        while (temp)
        {
            if (temp % 10 == 0 || i % (temp % 10) != 0)
            {
                break;
            }
            temp /= 10;
        }

        if (temp != 0)
        {
            continue;
        }
        else
        {
            ans[(*returnSize)++] = i;
        }
    }
    return ans;
}

744.寻找比目标字母大的最小字母
char nextGreatestLetter(char* letters, int lettersSize, char target) {
    if (letters[0] > target || letters[lettersSize - 1] <= target)
    {
        return letters[0];
    }

    int l = 0, r = lettersSize - 1, mid;
    while (l < r)
    {
        mid = (l + r) / 2;
        if (letters[mid] > target && letters[mid - 1] <= target)
        {
            return letters[mid];
        }
        else if (letters[mid] > target && letters[mid - 1] > target)
        {
            r = mid - 1;
        }
        else if (letters[mid] <= target)
        {
            l = mid + 1;
        }
    }
    mid = (l + r) / 2;
    return letters[mid];
}

747.至少是其他数字两倍的最大数
int dominantIndex(int* nums, int numsSize) {
    int max1 = 0, max2 = 0, pos = 0;
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] > max1)
        {
            max2 = max1;
            max1 = nums[i];
            pos = i;
        }
        else if (nums[i] > max2)
        {
            max2 = nums[i];
        }
    }

    if (max1 >= 2 * max2)
    {
        return pos;
    }
    else
    {
        return -1;
    }
}

748.最短补全词
char* shortestCompletingWord(char* licensePlate, char** words, int wordsSize) {
    int arr[26] = { 0 };
    while (*licensePlate != '\0')
    {
        if (*licensePlate >= 'A' && *licensePlate <= 'Z')
        {
            arr[*licensePlate + 32 - 'a']++;
        }
        else if (*licensePlate >= 'a' && *licensePlate <= 'z')
        {
            arr[*licensePlate - 'a']++;
        }
        licensePlate++;
    }

    int ans = 15, pos = 0;
    for (int i = 0; i < wordsSize; i++)
    {
        int brr[26] = { 0 };
        int flag = 0;

        for (int j = 0; j < strlen(words[i]); j++)
        {
            brr[words[i][j] - 'a']++;
        }

        for (int k = 0; k < 26; k++)
        {
            if (brr[k] < arr[k])
            {
                flag = 1;
                break;
            }
        }

        if (flag == 0)
        {
            if (strlen(words[i]) < ans)
            {
                ans = strlen(words[i]);
                pos = i;
            }
        }
    }
    return words[pos];
}